﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MyVoteMVC.Web.Models.Item>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    活动详细
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script language="JavaScript">
        function saveTicket() {
            $("#btnsave").attr('disabled', 'disabled');
            document.forms[0].method = "post";
            document.forms[0].action = document.forms[0].action.replace('ProjectDetails', 'Save');
            document.forms[0].submit();
            return true;
        }

        function submitTicket() {
            $("#btnsubmit").attr('disabled', 'disabled');
            document.forms[0].method = "post";
            document.forms[0].action = document.forms[0].action.replace('ProjectDetails', 'Save');
            document.forms[0].action = document.forms[0].action.replace('Save', 'Submit');
            document.forms[0].submit();
            return true;
        }
        if ('<%= TempData["ModelErrorMsg"] %>' != '') {
            alert('<%= TempData["ModelErrorMsg"] %>');
        }
    </script>
    <% Html.BeginForm(); %>
    <%: Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.") %>
    <div>
        <div class="title">
          <h1><%= Model.Count()>0 ? Model.FirstOrDefault().ActivityTitle:string.Empty %><span></span></h1>
          <p><%= Model.Count() > 0 ? Model.FirstOrDefault().ActivityContent : string.Empty%></p>
        </div>
        
        <div id="demo" class="demo" style="background:#1c1c1c;">
        <% string[] checkedRecords = (string[])ViewData["checkedRecords"];
           
           foreach (IGrouping<string, Item> Group in Model.GroupBy(o => o.QID))
           {%>
           
        <ul class="splitter">   
        <li><%= Group.First().QuestionTitle%>:<%= Group.First().QuestionContent %></li> 
        </ul>        
            <ul id="list-<%= Group.Key %>" class="image-grid imagelist">
        <%
               foreach (Item Item in Group)
               { 
                   %>
                <li data-id="id-<%= Item.ID %>"><a class="gallerybox"
                    rel="fancybox-button" href="<%= Url.Content("~/Image/ImageByItemID/" + Item.ID) %>"
                    title="<%= Item.Title %>" description="选项描述：<%= Item.Content %>">
                    <img src="<%= Url.Content("~/Image/ThumbnailByItemID/" + Item.ID) %>" border="0" alt="" />
                </a><% if ((bool)ViewData["ticketSubmit"])
                       {%>
                    <input name="<%= Item.QID %>" type="checkbox" value="<%= Item.ID %>" <% if (checkedRecords.Contains(Item.ID)) {
             %> checked="checked" <%} %> /><strong><%= Item.Title %></strong><%}
                       else
                       { %>
                    <strong><%= Item.Title %></strong>[<%= Item.Online_Count%>/<%= Item.Offline_Count%>]
                    <%} %>
                </li>
                <%
               } %></ul><%
           } %>
        </div>

        <ul class="splitter">            
            <li>
                <% if ((bool)ViewData["ticketSubmit"])
                   {%>
                <button class="t-button" id="btnsubmit" onclick="submitTicket()">
                    确定投票</button>
                <button class="t-button" id="btnsave" onclick="saveTicket()">
                    临时保存</button><%}
                   else
                   {%>&nbsp; <a class="t-button" target="_blank" href="<%= Url.Action("VoteResult","Home",new {id = ViewContext.RouteData.Values["ID"].ToString()}) %>">
                       查看结果</a>
                <%} %></li>
        </ul>
        <% Html.EndForm(); %>        
        </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    
    
</asp:Content>
